package com.katze.boot.file.entity;

public class FileSystemResource extends FileSystem{

    private static final long serialVersionUID = -7061042874689921297L;

    public FileSystemResource() {}

    public FileSystemResource(Object entity) {
        if (entity instanceof FolderEntity) {
            setId(((FolderEntity) entity).getId());
            setName(((FolderEntity) entity).getName());
            setExtension("folder");
            setSize(0L);
            setParentId(((FolderEntity) entity).getFileDatabaseId());
            setCreateTime(((FolderEntity) entity).getCreateTime());
            setChangeTime(((FolderEntity) entity).getCreateTime());
        } else if (entity instanceof FileEntity) {
            setId(((FileEntity) entity).getId());
            setName(((FileEntity) entity).getName());
            setExtension(((FileEntity) entity).getExtension());
            setSize(((FileEntity) entity).getSize());
            setParentId(((FileEntity) entity).getFileDatabaseExtendId());
            setDescription(((FileEntity) entity).getDescription());
            setCreateTime(((FileEntity) entity).getCreateTime());
            setChangeTime(((FileEntity) entity).getUpdateTime() == null? ((FileEntity) entity).getCreateTime():((FileEntity) entity).getUpdateTime());
        }
    }
}
